Page({
  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },

  onLoad() {
    this.getUserInfo()
  },
  // 获取个人信息
  async getUserInfo() {
    if (!getApp().token) return
    const {
      data,
      code
    } = await wx.http.get('/userInfo')
    if (code !== 10000) return wx.utils.toast('获取信息失败')
    this.setData({
      nickName: data.nickName,
      avatar: data.avatar,
    })
  },
})